set more off

gl OLB ""

*********
*Figure 1
*********
use "$OLB\table_1_2_3", clear
sum price, detail
keep if price>r(p5) & price<r(p95)
# delimit ;
twoway (lpolyci belief return if own==1, clc(maroon) acol(maroon*.1) level(95)) 
	(lpolyci belief return if own==0, clc(navy) acol(navy*.1) level(95)), 
	scheme(s1color) 
	legend(label(1 "Own") label(3 "Not Own") order(1 3))
	xtitle("Return (%)")
	xlabel(-30(10)50)
	ytitle("Belief")
	;
# delimit cr

*********
*Figure 2
*********
use "$OLB\table_1_2_3", clear
sum price, detail
keep if price>r(p5) & price<r(p95)
# delimit ;
twoway (lpolyci belief_error return if own==1, clc(maroon) acol(maroon*.1) level(95)) 
	(lpolyci belief_error return if own==0, clc(navy) acol(navy*.1) level(95)), 
	scheme(s1color) 
	legend(label(1 "Own") label(3 "Not Own") order(1 3))
	xtitle("Return (%)")
	xlabel(-30(10)50)
	ylabel(-6(3)3)
	ytitle("Belief Error")
	;
# delimit cr

*********
*Figure 3
*********
use "$OLB\table_7", clear
g uno=1
replace cummulative_rating=cummulative_rating+3
g positive=cummulative_rating>=4.5 if cummulative_rating!=.
g neutral=cummulative_rating<4.5 & cummulative_rating>=3.5 if cummulative_rating!=.
g negative=cummulative_rating<3.5 if cummulative_rating!=.
foreach var in positive neutral negative{
	g own_`var'=own*`var'
	}

reghdfe value own_positive own_neutral own_negative positive neutral negative, absorb(uno) cluster(id)
preserve
clear
set obs 6
g t=_n-1
replace t=.65 if t==0
replace t=4.35 if t==5
g coef=.
g ub=.
g lb=.
*Values from no information treatment
replace coef=5.535354 if t==1	
replace ub=9.471045 if t==1
replace lb=1.599662 if t==1
g base_coef=5.535354

local i=2
foreach var in own_negative own_neutral own_positive{
	replace coef=_b[`var'] if t==`i'
	replace ub=_b[`var'] + invttail(e(df_r),0.025)*_se[`var'] if t==`i'
	replace lb=_b[`var'] - invttail(e(df_r),0.025)*_se[`var'] if t==`i'
	local i=`i'+1
	}

# delimit ;
twoway (bar coef t if t==1, barw(.7) color(maroon))
	(bar coef t if t!=1, barw(.7) color(navy))
	(rcap lb ub t, lcolor(gs10) lw(medthick))
	(line base_coef t, lcolor(maroon) lw(medthick) lpattern(dash))
	, 
	scheme(s1color)
	xlabel(1 "No Information" 2 "Negative" 3 "Neutral" 4 "Positive" )
	yline(0, lcolor(black))
	xtitle("")
	ytitle("WTA-WTP")
	legend(off)
	ylabel(-10(5)15)
	;
# delimit cr

*********
*Figure 4
*********
*Panel A
use "$OLB\figure_4", clear
g Own_good=price_increase==1 & own_retained==1
g Own_bad=price_increase==0 & own_retained==1
g NoOwn_good=price_increase==1 & own_retained==0
g NoOwn_bad=price_increase==0 & own_retained==0

reg belief_change Own_good Own_bad NoOwn_good NoOwn_bad, cluster(id) nocons
g grp=_n-3
g b=.
g u=.
g d=.
replace b=_b[Own_bad] if grp==-2
replace u=_b[Own_bad] + invttail(e(df_r),0.025)*_se[Own_bad] if grp==-2
replace d=_b[Own_bad] - invttail(e(df_r),0.025)*_se[Own_bad] if grp==-2
replace b=_b[NoOwn_bad] if grp==-1
replace u=_b[NoOwn_bad] + invttail(e(df_r),0.025)*_se[NoOwn_bad] if grp==-1
replace d=_b[NoOwn_bad] - invttail(e(df_r),0.025)*_se[NoOwn_bad] if grp==-1
replace b=_b[Own_good] if grp==1
replace u=_b[Own_good] + invttail(e(df_r),0.025)*_se[Own_good] if grp==1
replace d=_b[Own_good] - invttail(e(df_r),0.025)*_se[Own_good] if grp==1
replace b=_b[NoOwn_good] if grp==2
replace u=_b[NoOwn_good] + invttail(e(df_r),0.025)*_se[NoOwn_good] if grp==2
replace d=_b[NoOwn_good] - invttail(e(df_r),0.025)*_se[NoOwn_good] if grp==2

g grpT=-1.7 if grp==-2
replace grpT=-1.3 if grp==-1
replace grpT=1.3 if grp==1
replace grpT=1.7 if grp==2

# delimit ;
twoway (bar b grpT if grp==-2, barw(.33) color(navy))
	(bar b grpT if grp==-1, barw(.33) color(maroon))
	(rcap  d u grpT if grp==-2 | grp==-1, color(gray)),
	scheme(s1color)
	yline(0, lcolor(black))
	ylabel(-4(2)4)
	xscale(range(-2 -1))
	xlabel("")
	xtitle("")
	legend(label(1 "Own") label(2 "Not Own") order(1 2))
	saving("$OLB\badnews", replace)
	title("Bad News")
	;
# delimit cr

# delimit ;
twoway (bar b grpT if grp==1, barw(.33) color(navy))
	(bar b grpT if grp==2, barw(.33) color(maroon))
	(rcap  d u grpT if grp==1 | grp==2, color(gray)),
	scheme(s1color)
	yline(0, lcolor(black))
	ylabel(-4(2)4)
	xscale(range(1 2))
	xlabel("")
	xtitle("")
	legend(label(1 "Own") label(2 "Not Own") order(1 2))
	saving("$OLB\goodnews", replace)
	title("Good News")
	;
# delimit cr
grc1leg  "$OLB\badnews" "$OLB\goodnews", legendfrom("$OLB\badnews") scheme(s1color) title("Panel A: Participants who Retain Ownership")

*Panel B
use "$OLB\figure_4", clear
g Own_good=price_increase==1 & own_corrected==1
g Own_bad=price_increase==0 & own_corrected==1
g NoOwn_good=price_increase==1 & own_corrected==0
g NoOwn_bad=price_increase==0 & own_corrected==0

reg belief_change Own_good Own_bad NoOwn_good NoOwn_bad, cluster(id) nocons
g grp=_n-3
g b=.
g u=.
g d=.
replace b=_b[Own_bad] if grp==-2
replace u=_b[Own_bad] + invttail(e(df_r),0.025)*_se[Own_bad] if grp==-2
replace d=_b[Own_bad] - invttail(e(df_r),0.025)*_se[Own_bad] if grp==-2
replace b=_b[NoOwn_bad] if grp==-1
replace u=_b[NoOwn_bad] + invttail(e(df_r),0.025)*_se[NoOwn_bad] if grp==-1
replace d=_b[NoOwn_bad] - invttail(e(df_r),0.025)*_se[NoOwn_bad] if grp==-1
replace b=_b[Own_good] if grp==1
replace u=_b[Own_good] + invttail(e(df_r),0.025)*_se[Own_good] if grp==1
replace d=_b[Own_good] - invttail(e(df_r),0.025)*_se[Own_good] if grp==1
replace b=_b[NoOwn_good] if grp==2
replace u=_b[NoOwn_good] + invttail(e(df_r),0.025)*_se[NoOwn_good] if grp==2
replace d=_b[NoOwn_good] - invttail(e(df_r),0.025)*_se[NoOwn_good] if grp==2

g grpT=-1.7 if grp==-2
replace grpT=-1.3 if grp==-1
replace grpT=1.3 if grp==1
replace grpT=1.7 if grp==2

# delimit ;
twoway (bar b grpT if grp==-2, barw(.33) color(navy))
	(bar b grpT if grp==-1, barw(.33) color(maroon))
	(rcap  d u grpT if grp==-2 | grp==-1, color(gray)),
	scheme(s1color)
	yline(0, lcolor(black))
	ylabel(-4(2)4)
	xscale(range(-2 -1))
	xlabel("")
	xtitle("")
	legend(label(1 "Own") label(2 "Not Own") order(1 2))
	saving("$OLB\badnews", replace)
	title("Bad News")
	;
# delimit cr

# delimit ;
twoway (bar b grpT if grp==1, barw(.33) color(navy))
	(bar b grpT if grp==2, barw(.33) color(maroon))
	(rcap  d u grpT if grp==1 | grp==2, color(gray)),
	scheme(s1color)
	yline(0, lcolor(black))
	ylabel(-4(2)4)
	xscale(range(1 2))
	xlabel("")
	xtitle("")
	legend(label(1 "Own") label(2 "Not Own") order(1 2))
	saving("$OLB\goodnews", replace)
	title("Good News")
	;
# delimit cr
grc1leg  "$OLB\badnews" "$OLB\goodnews", legendfrom("$OLB\badnews") scheme(s1color) title("Panel B: Correcting for Selection")


********
*Table 1
********
use "$OLB\table_1_2_3", clear
g uno=1
g own_return=own*return
reghdfe belief own_return return own, absorb(uno) cluster(id)	
reghdfe belief own_return own, absorb(rndprc) cluster(id)	
reghdfe belief own_return own, absorb(rndprc id) cluster(id)


********
*Table 2
********
use "$OLB\table_1_2_3", clear
g uno=1
g own_return=own*return
reghdfe belief_error own_return return own, absorb(uno) cluster(id)
reghdfe belief_error own_return return own, absorb(id) cluster(id)
reghdfe belief_error own_return return own if discrete==1, absorb(uno) cluster(id)
reghdfe belief_error own_return return own if discrete==1, absorb(id) cluster(id)
reghdfe belief_error own_return return own if discrete==0, absorb(uno) cluster(id)
reghdfe belief_error own_return return own if discrete==0, absorb(id) cluster(id)


********
*Table 3
********
use "$OLB\table_1_2_3", clear
g uno=1
g own_price_increase=own*price_increase

*Panel A
reghdfe belief own_price_increase price_increase own, absorb(uno) cluster(id)	
reghdfe belief_error own_price_increase price_increase own, absorb(uno) cluster(id)
reghdfe beta_own_error own_price_increase price_increase own, absorb(uno) cluster(id)
reghdfe beta_round_own_error own_price_increase price_increase own, absorb(uno) cluster(id)

*Panel B
g Dprice60=price<70 if price!=.
forvalues i=70(10)150{
	g Dprice`i'=price>=`i' & price<(`i'+10)
	}
g Dprice160=price>=160
forvalues i=60(10)160{
	g own_Dprice`i'=own*Dprice`i'
	}
drop Dprice100
drop own_Dprice100
g own_return=own*return
reghdfe belief own_price_increase price_increase own return, absorb(uno) cluster(id)
reghdfe belief own_price_increase price_increase own Dprice*, absorb(uno) cluster(id)
reghdfe belief own_price_increase price_increase own return own_return, absorb(uno) cluster(id)
reghdfe belief own_price_increase price_increase own  Dprice* own_Dprice*, absorb(uno) cluster(id)


********
*Table 4
********
*Panel A
use "$OLB\table_4", clear
g uno=1
g own_return=own*return
keep if high_attention==1
reghdfe belief own_return return own, cluster(id) absorb(uno)
reghdfe belief own_return own, cluster(id) absorb(rndprc)
reghdfe belief own_return own, cluster(id) absorb(rndprc id)
reghdfe belief_error own_return return own, cluster(id) absorb(uno)
reghdfe belief_error own_return return own, cluster(id) absorb(id)

use "$OLB\table_4", clear
g uno=1
g own_return=own*return
keep if high_attention==0
reghdfe belief own_return return own, cluster(id) absorb(uno)
reghdfe belief own_return own, cluster(id) absorb(rndprc)
reghdfe belief own_return own, cluster(id) absorb(rndprc id)
reghdfe belief_error own_return return own, cluster(id) absorb(uno)
reghdfe belief_error own_return return own, cluster(id) absorb(id)

********
*Table 5
********
*Panel A
use "$OLB\table_5", clear
g uno=1
g no_own_treat_return=no_own_treat*return
g own_return=own*return*(no_own_treat==0)
reghdfe belief no_own_treat_return own_return return own no_own_treat, absorb(uno) cluster(id)
reghdfe belief no_own_treat_return own_return own no_own_treat, absorb(rndprc) cluster(id)	
reghdfe belief_error no_own_treat_return own_return return own no_own_treat, absorb(uno) cluster(id)	

*Panel B
use "$OLB\table_5", clear
g uno=1
g no_own_treat_price_increase=no_own_treat*price_increase
g own_price_increase=own*price_increase*(no_own_treat==0)
reghdfe belief no_own_treat_price_increase own_price_increase price_increase own no_own_treat, absorb(uno) cluster(id)
reghdfe belief no_own_treat_price_increase own_price_increase price_increase own no_own_treat, absorb(rndprc) cluster(id)	
reghdfe belief_error no_own_treat_price_increase own_price_increase price_increase own no_own_treat, absorb(uno) cluster(id)	

********
*Table 6
********
use "$OLB\table_6", clear
reg correct ABSreturn
areg correct own ABSreturn, absorb(ABSquality)
areg correct own ABSreturn if match==1, absorb(ABSquality)
areg correct own ABSreturn if match==0, absorb(ABSquality)

********
*Table 7
********
use "$OLB\table_7", clear
g uno=1
g own_cummulative_rating=own*cummulative_rating

*Panel A
reghdfe value own_cummulative_rating cummulative_rating own trade_paradigm, absorb(uno) cluster(id)
reghdfe value own_cummulative_rating cummulative_rating own trade_paradigm, absorb(id) cluster(id)
reghdfe value own_cummulative_rating cummulative_rating own trade_paradigm, absorb(round) cluster(id)
reghdfe value own_cummulative_rating own trade_paradigm, absorb(rpinfo) cluster(id)
reghdfe value own_cummulative_rating own trade_paradigm, absorb(id rpinfo) cluster(id)

g own_last_rating=own*last_rating
*Panel B
reghdfe value own_last_rating last_rating own trade_paradigm, absorb(uno) cluster(id)
reghdfe value own_last_rating last_rating own trade_paradigm, absorb(id) cluster(id)
reghdfe value own_last_rating last_rating own trade_paradigm, absorb(round) cluster(id)
reghdfe value own_last_rating own trade_paradigm, absorb(rpinfo) cluster(id)
reghdfe value own_last_rating own trade_paradigm, absorb(id rpinfo) cluster(id)


